#!/usr/bin/env python
# coding=utf-8
"""
@Author  : youjia - 卞志伟
@file    : 改价_十月一.py
@contact : bianzhiwei@iyoujia.com
@time    : 2019-09-04 14:27 
@Desc    : 
@Software: PyCharm
"""
import os
import sys

# 当前文件的路径
pwd, filename = os.path.split(os.path.abspath(__file__))
# 当前文件的父路径
father_path = os.path.abspath(os.path.dirname(pwd) + os.path.sep + ".")
# 当前文件的前两级目录
grader_father = os.path.abspath(os.path.dirname(pwd) + os.path.sep + "..")
sys.path.append(pwd)
sys.path.append(father_path)
sys.path.append(grader_father)

import pandas as pd
from report_system.utils import db_util
from report_system.utils import excel_util

sql = """SELECT u.realname ,lp.remark,lp.create_time
FROM youjia.lod_operations lp
left join youjia.users u on u.id = lp.creator_id
where lp.remark like '%2019-10-01%'
"""

df = pd.read_sql_query(sql, db_util.con_youjia)
# result_df['rate_fair20'] = result_df.apply(lambda row: str(round(100 * row.rate_fair20)) + '%', axis=1)
df['途家'] = df.apply(lambda row: "途家" if "渠道id:3" in row['remark'] else "", axis=1)
df['榛果'] = df.apply(lambda row: "榛果" if "渠道id:25" in row['remark'] else "", axis=1)
df['Airbnb'] = df.apply(lambda row: "Airbnb" if "渠道id:20" in row['remark'] else "", axis=1)

excel_util.pd_to_excel({"df": df}, "0")
